﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PowerCreator.LMS.DL.Project.Entity;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Common.Utils;
using PowerCreator.LMS.Web.DL.Project;
using PowerCreator.LMS.Web.Catalog;
using PowerCreator.LMS.Web.User;
using PowerCreator.LMS.Web.Course;
using Telerik.WebControls;


public partial class sysadmin_DL_Project_ManageNofinishClassTaskUserList :PowerCreator.LMS.Web.Base.WebBasePage
{
    PowerCreator.LMS.ViewQuery.ViewQuery obj = new PowerCreator.LMS.ViewQuery.ViewQuery();
    VOTOClassTasks voClassTask = new VOTOClassTasks();
    TOClassTasks objClassTask = new TOClassTasks();
    private VOTOClass voClass = new VOTOClass();
    TOClass objClass = new TOClass();
    VOTOClassTasksReply votaskreply = new VOTOClassTasksReply();
    TOClassTasksReply objtaskReply = new TOClassTasksReply();
    PowerCreator.LMS.ViewQuery.ViewQuery ov = new PowerCreator.LMS.ViewQuery.ViewQuery();
    PowerCreator.LMS.Course.Entity.VOTOCourse vocourse = new PowerCreator.LMS.Course.Entity.VOTOCourse();
    PowerCreator.LMS.Web.Course.Course objcourse = new PowerCreator.LMS.Web.Course.Course();

    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {

            string ctid = "0";
            string courseid = "0";
            string cid = "0";
            if (Request.QueryString["CID"] != null)
            {
                cid = Request.QueryString["CID"].ToString();
                if (cid.Length > 0)
                {
                    voClass = objClass.Load(int.Parse(cid));
                    lbl_class.Text = voClass.Name;
                }
            }
            if (Request.QueryString["CourseID"] != null)
            {
                courseid = Request.QueryString["CourseID"].ToString();
                if (courseid.Length > 0)
                {
                    vocourse = objcourse.LoadVOTCourse(int.Parse(courseid));
                    lbl_Course.Text = vocourse.CourseName;
                }
                else
                    lbl_Course.Text = "综合";
            }

            if (Request.QueryString["CTID"] != null)
            {
                ctid = Request.QueryString["CTID"].ToString();
                ViewState["CTID"] = ctid.ToString();
                //voClass = objClass.Load(CID);
                //ClassName = voClass.Name;
                string sql=GetSearch(cid,ctid);
                BinderPG(sql,1);
            }

        }
    }


    private string GetSearch(string cid,string ctid)
    {
        string search = "SELECT Learner_Id,UserName,Name AS RealName,  TO_Learner.TeacherId  FROM TO_Learner where 1=1";
        //if (!string.IsNullOrEmpty(txt_KeyWord.Text))
        //    search = string.Format(" and (Name like '%{0}%' or UserName like '%{0}%')", txt_KeyWord.Text.Trim());
        search =search+ string.Format(" and (Learner_Id in (select UserID from TO_UserOfClass where ClassID={0}) and  Learner_Id not in (select Creator from TO_UserClassTask where Task_Id={1}))",cid,ctid);
        return search;
    }


    private void BinderPG(string search, int pageIndex)
    {
        if (ViewState["CTID"] != null)
        {
            string orderby = " Learner_Id desc";
            DataTable dt = obj.Query(search, orderby, LMSPageSize, pageIndex);
            lbl_nofinishnum.Text = dt.Rows.Count.ToString();
            rptNew.DataSource = dt;
            rptNew.DataBind();
        }

    }


    //protected void btnSearch_Click(object sender, EventArgs e)
    //{
    //    if (ViewState["CTID"] != null & ViewState["CID"] != null)
    //    {
    //        string sql = GetSearch(ViewState["CID"].ToString(), ViewState["CTID"].ToString());
    //        BinderPG(sql, 1);
    //    }
        
    //}
}
